<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Natoo开源版</title>
    <meta name="keywords" content="qadmin,qadmin模板,后台模板,qadmin后台模板">
    <meta name="description" content="qadmin是一个轻量级后台模板,基于layui框架开发,简洁而不简单">
    <link rel="stylesheet" href="./assets/layui/css/layui.css">
    <link rel="stylesheet" href="./assets/admin/css/login.css">
    <script src="./assets/js/jquery-3.3.1.min.js"></script>
    <script src="./assets/layui/layui.js"></script>
</head>

<body id="login">
<div class="login">
    <h2>Natoo内网穿透</h2>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <input type="username" name="username" placeholder="用户名" class="layui-input">
            <i class="layui-icon input-icon">&#xe66f;</i>
        </div>
        <div class="layui-form-item">
            <input type="password" name="password" placeholder="密码" class="layui-input">
            <i class="layui-icon input-icon">&#xe673;</i>
        </div>
        <div class="layui-form-item">
            <input type="checkbox" name="box" lay-skin="primary" title="记住密码" checked=""> <a class="back"
                                                                                             href="javascript:;"
                                                                                             style="margin-top: 10px">忘记密码</a>
        </div>
        <div class="layui-form-item">
            <button style="width: 100%" class="layui-btn" lay-submit lay-filter="login">立即登录</button>

        </div>
    </form>

    <script>
layui.use('form', function() {
    const form = layui.form;
    const layer = layui.layer;

    form.on('submit(login)', function(data) {
        var cid=layer.load({
            shade: 0.5,
            time: 0,
        });

        $.ajax({
            url:'/login.do',
            type:'post',
            data:data.field,
            success: function (ret) {
                console.log(ret)
                layer.alert(ret.msg);
                if (ret.code == 0) {
                    location.href = '/index.html';
                }
            },
            complete: function () {
                layer.close(cid);
            }
        })

        return false;
    });
});
    </script>
</div>
</body>

</html>
